<template>
  <view class="coupon-item">
    <view class="coupon-money">
      <view class="layof" :style="{ color: theme }">{{ item.couponName }}</view>
      <!-- <view class="demand">{{ item.couponName }}</view> -->
    </view>
    <view class="coupon-desc">
      <view class="coupon-desc-text">
        <!-- <view class="nick">{{ item.nick }}</view> -->
        <view class="end_time">有效期:{{ item.couponPrescription }}</view>
        <view class="rules" @click="showRules(item)">使用规则>></view>
      </view>
      <view
        class="get-btn"
        :style="{ color: color, borderColor: color, background: solid }"
        @click="toUse"
        >立即使用</view
      >
    </view>
    <u-popup
      :closeable="true"
      :round="10"
      :show="show"
      mode="center"
      @close="close"
      @open="open"
      :customStyle="{
        width: '400rpx',
        height: '400rpx',
        padding: '80rpx',
      }"
    >
      <view class="rules-box">
        <text>{{ item.couponName }}</text>
      </view>
    </u-popup>
  </view>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      show: false,
    };
  },
  props: {
    item: {
      type: Object,
    },
    types: {
      type: String,
      default: "",
    },
    theme: {
      type: String,
      default: "#ff9000",
    },
    solid: {
      type: String,
      default: "#ffffff",
    },
    color: {
      type: String,
      default: "#ff9000",
    },
  },
  methods: {
    showRules() {
      this.show = true;
    },
    open() {
      // console.log('open');
    },
    toUse() {
      uni.navigateTo({
        url: '/nursingWorkerPages/pages/index/index?couponId=' + this.item.id
      })
    },
    close() {
      this.show = false;
      // console.log('close');
    },
  },
};
</script>

<style lang="scss">
/* 页面左右间距 */
$page-row-spacing: 30rpx;
$page-color-base: #f8f8f8;
$page-color-light: #f8f6fc;
$page-p-l-t-r-30: 30rpx 30rpx 0 30rpx;
$page-p-20: 30rpx;

/* 文字尺寸 */
$font-sm: 24rpx;
$font-base: 28rpx;
$font-lg: 32rpx;

/*文字颜色*/
$font-color-dark: #303133;
$font-color-base: #606266;
$font-color-light: #909399;
$font-color-disabled: #c0c4cc;
$font-color-spec: #d6003c;
$font-color-gray: #999999;
$font-color-red: #dd0037;
$font-color-ccc: #cccccc;
$font-color-999: #999999;
$font-color-666: #666666;
$font-color-333: #333333;
$font-color-000: #000000;

/* 边框颜色 */
$border-color-dark: #dcdfe6;
$border-color-base: #e4e7ed;
$border-color-light: #ebeef5;

/* 背景颜色 */
$image-bg-color: #eeeeee;
$bgcolor_white: #ffffff;
$all_bgcolor: #f4f4f4;
$vui_bgcolor: #8c0027;

/* 行为相关颜色 */
$color-primary: #fa436a;
$color-success: #4cd964;
$color-warning: #f0ad4e;
$color-error: #dd524d;
.coupon-item {
  width: 100%;
  height: 200rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 10rpx;
  padding: 0 20rpx;
  margin-top: 22rpx;
  border: 1px solid #eeeeee;
  position: relative;
  .coupon-money {
    width: 305rpx;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 26rpx 0;
    border-style: none dotted none none;
    border-color: #eeeeee;

    .tit {
      width: 100%;
      height: 50rpx;
      line-height: 50rpx;
      font-size: $font-sm;
      color: $font-color-999;
    }
    .demand {
      width: 100%;
      height: 30rpx;
      line-height: 30rpx;
      font-size: $font-sm;
      color: $font-color-999;
    }

    .layof {
      width: 100%;
      height: 48rpx;
      line-height: 30rpx;
      font-size: 38rpx;
      color: #ff9000;
      font-weight: bold;
      text-align: center;
    }
    .end_time {
      width: 100%;
      height: 30rpx;
      line-height: 30rpx;
      font-size: $font-sm;
      color: $font-color-999;
    }
  }
  .coupon-desc {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    .coupon-desc-text {
      width: 80%;
      padding-left: 30rpx;
      text-align: center;
      .nick {
        width: 100%;
        height: 50rpx;
        line-height: 30rpx;
        font-size: $font-base;
        color: $font-color-000;
        font-weight: 700;
      }
      .rules {
        width: 100%;
        height: 50rpx;
        font-size: $font-base;
        color: $font-color-000;
      }
    }
  }

  .get-btn {
    width: 146rpx;
    height: 52rpx;
    line-height: 50rpx;
    // margin-top: -26rpx;
    text-align: center;
    border-radius: 60rpx;
    color: #ff9000;
    border: 1px solid #ff9000;
    font-size: $font-sm;
  }
}
.coupon-item:after {
  width: 40rpx;
  height: 20rpx;
  position: absolute;
  left: 205rpx;
  top: -1px;
  border-radius: 0 0 40rpx 40rpx;
  content: "";
  display: block;
  background: $bgcolor_white;
  border: 1px solid #eeeeee;
  border-top: 0px;
}
.coupon-item:before {
  width: 40rpx;
  height: 20rpx;
  position: absolute;
  left: 205rpx;
  bottom: -1px;
  border-radius: 40rpx 40rpx 0 0;
  content: "";
  display: block;
  background: $bgcolor_white;
  border: 1px solid #eeeeee;
  border-bottom: 0px;
}
.coupon-desc {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.rules-box {
  width: 100%;
}
</style>
